﻿using System.Linq;

namespace HooIzDat.Web.Models
{
    public class PlayerRepository : Repository, IPlayerRepository
    {
        public IQueryable<Player> FindAll()
        {
            return Db.Players;
        }

        public Player GetPlayer(string userName)
        {
            return Db.Players.SingleOrDefault(p => p.UserName == userName);
        }

        public void Add(Player player)
        {
            Db.Players.AddObject(player);
        }

        public void Delete(Player player)
        {
            Db.Players.DeleteObject(player);
        }

        public void Save()
        {
            Db.SaveChanges();
        }
    }
}